﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Page/Site.Master" AutoEventWireup="true" CodeBehind="PageTest.aspx.cs" Inherits="ERP.Page.PageTest" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script>
    $(document).ready(function () {
        alert(<%=btnSave.UniqueID %>);
    })
</script>
<script>
    var isCtrlKey = false;
    document.onkeyup = function (e) {
        if (e.which == 17) isCtrlKey = false;
    }
    document.onkeydown = function (e) {
        if (e.which == 17) isCtrlKey = true;

        //CTRL + S
        if (e.which == 83 && isCtrlKey == true) {
            TriggerSaveButton();
            StopDefaultAction(e);

            //CTRL + N
        } else if (e.which == 78 && isCtrlKey == true) {
            TriggerNextButton();
            StopDefaultAction(e);

            //CTRL + P
        } else if (e.which == 80 && isCtrlKey == true) {
            TriggerPreviousButton();
            StopDefaultAction(e);
        }
    }

    function StopDefaultAction(e) {
        if (e.preventDefault) { e.preventDefault() }
        else { e.stop() };

        e.returnValue = false;
        e.stopPropagation();
    }

    <%--function TriggerPreviousButton() {
        javascript: __doPostBack('<%=btnPrevious.UniqueID %>', '');
    }--%>

    function TriggerSaveButton() {
        
        javascript: __doPostBack('<%=btnSave.UniqueID %>', '');
        
    }

   function TriggerNextButton() {
        javascript: __doPostBack('<%=btnAddNew.UniqueID %>', ''); 
    }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="Button1_Click" />
        <asp:Button ID="btnAddNew" runat="server" Text="Add New" OnClick="Button2_Click" />
        <asp:Label ID="lbTest" runat="server" Text="Emty"></asp:Label>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </ContentTemplate>
</asp:UpdatePanel>

</asp:Content>
